#ifndef _APP_SERVERACCEPTER_H_
#define _APP_SERVERACCEPTER_H_

#include "net/net.h"

#include "iserverwatcherhandler.h"

namespace app {

class Server;
class Connection;

class ServerAccepter : public net::IAccepterHandler, public IServerWatcherHandler {
private:
    Server& server;

public:
    ServerAccepter(Server& server);
    ~ServerAccepter();

private: /* Internal */
    bool IsServer(net::ISocket* socket);
    void InitConnection(net::ISocket* socket, Connection* connection);

private: /* net::IAccepterHandler */
    virtual void OnAccept(net::ISocket* socket);

public: /* IServerWatcher */
    virtual void WatcherList(WATCHER_LIST& list);
    virtual void OnServerAdd(ServerInfo& server_info);
    virtual void OnServerRemove(ServerInfo& server_info);
};

}

#endif
